
package entities;

import java.text.NumberFormat;

/**
 * @version 1.0
 * @date 13/04/2012
 * @author john
 */
public final class AmountRange {
    
    public static final int INFINITE=-1;
    private int min;
    private int max;

    public AmountRange(int min){
        setMin(min);
        setMax(INFINITE);
    }
    
    public AmountRange(int min, int max) {
        setMin(min);
        setMax(max);
    }

    public int getMin() {
        return min;
    }

    public int getMax() {
        return max;
    }

    public void setMin(int min) {
        if(min<0)
            min=0;
        this.min=min;
    }

    public void setMax(int max) {
        if(max<0 || max<min)
            max=INFINITE;
        this.max=max;
    }
    
    @Override
    public String toString(){
        NumberFormat formatter=NumberFormat.getCurrencyInstance();
        if(min==0 && max==INFINITE)
            return "cualquier monto";
        if(min==0)
            return "menor a "+formatter.format(max);
        if(max==INFINITE)
            return "mayor a "+formatter.format(min);
        return formatter.format(min)+" - "+formatter.format(max);
    }
    
}